import Vue from "vue";
import VueRouter from "vue-router";

Vue.use(VueRouter);

const routes = [{
		path: "/",
		name: "Home",
		component: () =>
			import("../components/Index.vue")
	},
	// {
	// 	path: "/posts/create",
	// 	name: "Create",
	// 	component: () =>
	// 		import( /* webpackChunkName: "about" */ "../components/createText.vue")
	// },
	// {
	// 	path: "/posts/index",
	// 	name: "List",
	// 	component: () =>
	// 		import("../components/list.vue")
	// },

];

const router = new VueRouter({
	routes
});


//路由守卫
router.beforeEach((to, from, next) => {
	const auth = ["/index", "/"];
	if (auth.indexOf(to.fullPath) > -1) {
		console.log("需要处理")

		// store.commit("hideIndexTab")
		// this.$store.commit("hideIndexTab");
		next();
	} else {
		// store.commit("showIndexTab")
		next();
	}

})
export default router;